package com.omazan.srvlts;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.omazan.facace.models.UserSessionDetails;
import com.omazan.utils.Constants;

/**
 * Servlet implementation class ListUsers
 */
@WebServlet("/ListUsers")
public class ListUsers extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ListUsers() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		
		int type = Integer.parseInt(request.getParameter("userType"));
		if (1 == type) {
			UserSessionDetails userSessionDetails = (UserSessionDetails) request
					.getSession().getAttribute("userSessionDetails");
			userSessionDetails.setContentToLoad(Constants.listAdmins);
			response.sendRedirect("index.jsp");
		} else if (2 == type) {
			UserSessionDetails userSessionDetails = (UserSessionDetails) request
					.getSession().getAttribute("userSessionDetails");
			userSessionDetails.setContentToLoad(Constants.listEmp);
			response.sendRedirect("index.jsp");

		} else if (3 == type) {

			UserSessionDetails userSessionDetails = (UserSessionDetails) request
					.getSession().getAttribute("userSessionDetails");
			userSessionDetails.setContentToLoad(Constants.listCustomer);
			response.sendRedirect("index.jsp");

		}
	}

}
